home *** CD-ROM | disk | FTP | other *** search
/ Scene Storm / Scene Storm - Volume 1.iso / coding / asm / music / sampleplayers / play_samples_irq.s next >
Text File  |  1980-01-03  |  4KB  |  160 lines

  1. custom        =    $dff000
  2. aud0        =    $a0
  3. aud1        =    $b0
  4. aud2        =    $c0
  5. aud3        =    $d0
  6. channel        =    16
  7. dmacon        =    $96
  8. ac_ptr        =    0
  9. ac_len        =    4
  10. ac_per        =    6
  11. ac_vol        =    8
  12. DMAF_SETCLR    =    $8000
  13.  
  14.         section    chipmem,code_c
  15.         
  16. aa        cmp.b    #100,$dff006
  17.         bne.s    aa
  18.         
  19.         btst    #7,$bfe001
  20.         bne.w    no_retrig
  21.  
  22.         move.w    #$f00,$dff180
  23.         lea    sample,a0        ;sample data ptr
  24.         move.l    #sampleend-sample,d0    ;sample length
  25.         suba.l    a1,a1            ;repeat data ptr
  26.         moveq    #0,d1            ;repeat length
  27.         moveq    #0*channel,d2        ;channel number (n x16)
  28.         move.w    #304,d3            ;sample frequency (note period)
  29.         move.w    #$40,d4            ;sample volume        
  30.         bsr    notestart
  31.         move.w    #$bbc,$dff180
  32.  
  33. ee        btst    #7,$bfe001
  34.         beq.s    ee
  35.         
  36. no_retrig
  37.         btst    #6,$bfe001
  38.         bne.w    aa
  39.  
  40. bb        rts
  41.  
  42. *******************************************************************************
  43. * NoteStart - Start playing a note immediately
  44. * ---------
  45. * $Inputs:    a0.l = One-shot sample data
  46. *        a1.l = Repeat sample data
  47. *        d0.l = One-shot sample length (0 if no one-shot part)
  48. *        d1.l = Repeat sample length (0 if no repeat part)
  49. *        d2.b = Channel number
  50. *        d3.w = Sample frequency (if 0, then high word contains period)
  51. *        d4.w = Volume at which to play sample (0-$100)
  52. * $Outputs:    None
  53. *******************************************************************************
  54.  
  55. notestop    moveq   #0,d0
  56.         move.l    d0,d1
  57.  
  58. NoteStart:    lea    $dff000,a6        * Set the repeat pointers
  59.         lea    aud0(a6),a5        * $dff0a0 base..
  60.         move.w    d1,d5            * copy of repeat length
  61.         or.w    d0,d5            * replen & sample len = 0 ?
  62.         bne.s    setnote            * if so.. turn off note..
  63.         moveq   #0,d0            * erase d0
  64.         bset    d2,d0            * set dma bit to turn off dma
  65.         move.w  d0,dmacon(a6)        * turn off channel..
  66.         rts
  67.  
  68. setnote:    add.w    d2,a5            * channel base $dff0a0/b0/c0/d0
  69.  
  70. *-------------- check for sample len..
  71.  
  72.             lsr.w    #1,d0            * Stuff the one-shot pointers
  73.                bne.s    hasoneshot
  74.                moveq    #2,d0            * sample length (set to none)
  75.             suba.l    a0,a0            * sample data   (set to none)
  76.  
  77. hasoneshot:    move.w    d3,ac_per(a5)        * set period
  78.             move.w    d4,ac_vol(a5)        * set volume
  79.         move.l  a0,ac_ptr(a5)        * set sample data ptr
  80.             move.w  d0,ac_len(a5)        * set sample length
  81.  
  82.             moveq   #0,d0            * Turn DMA for this channel off
  83.                bset    d2,d0
  84.                move.w  d0,dmacon(a6)
  85.  
  86. *-------------- check for replen..
  87.  
  88.             lsr.w   #1,d1            * do sample repeat?
  89.             bne.s    hasrepeat
  90.             moveq   #2,d1            * repeat length (set to none)
  91.             suba.l    a1,a1            * repeat sample (set to none)
  92.  
  93. hasrepeat          lea     dmaflags(pc),a0
  94.             or.w    d0,(a0)            * save sample dma info..
  95.             move.b  d2,d0
  96.             move.w  d1,repeatlen-dmaflags(a0,d0.w*2)
  97.             move.l  a1,repeatptr-dmaflags(a0,d0.w*2)
  98.  
  99.         lea    $bfd000,a3
  100.         move.b    #$7f,$d00(a3)
  101.         move.w    #$2000,$09c(a6)
  102.         move.w    #$a000,$09a(a6)
  103.         lea    mt_irq1(pc),a4
  104.         move.l    _vbr(pc),a1
  105.         move.l    a4,$78(a1)
  106.         moveq    #0,d0
  107.         move.b    d0,$e00(a3)
  108.         move.b    #$a8,$400(a3)
  109.         move.b    d0,$500(a3)
  110.         move.b    #$11,$e00(a3)
  111.         move.b    #$81,$d00(a3)
  112.         or.w    #$8000,dmaflags
  113.         rts
  114.  
  115. mt_irq1        tst.b    $bfdd00
  116.         move.w    dmaflags(pc),$dff096
  117.         move.w    #$2000,$dff09c
  118.         movem.l    a0/a1,-(sp)
  119.         lea    mt_irq2(pc),a0
  120.         move.l    _vbr(pc),a1
  121.         move.l    a0,$78(a1)
  122.         movem.l    (sp)+,a0/a1
  123.         rte
  124.  
  125. mt_irq2        tst.b    $bfdd00
  126.         movem.l    a5-a6,-(sp)
  127.         lea    $dff000,a6
  128.                move.w  dmaflags(pc),d0
  129.         moveq    #1,d1
  130. chan0:        lsr.w    d1,d0
  131.             bcc.s    chan1
  132.             move.l  repeatptr+4*0(pc),aud0+ac_ptr(a6)
  133.             move.w  repeatlen+2*0(pc),aud0+ac_len(a6)
  134. chan1:        lsr.w   d1,d0
  135.             bcc.s    chan2
  136.             move.l  repeatptr+4*1(pc),aud1+ac_ptr(a6)
  137.             move.w  repeatlen+2*1(pc),aud1+ac_len(a6)
  138. chan2:            lsr.w   d1,d0
  139.             bcc.s    chan3
  140.             move.l  repeatptr+4*2(pc),aud2+ac_ptr(a6)
  141.             move.w  repeatlen+2*2(pc),aud2+ac_len(a6)
  142. chan3:            lsr.w   d1,d0
  143.             bcc.s    chandone
  144.             move.l  repeatptr+4*3(pc),aud3+ac_ptr(a6)
  145.             move.w  repeatlen+2*3(pc),aud3+ac_len(a6)
  146. chandone:    clr.w   dmaflags
  147.         clr.b    $bfde00
  148.         move.b    #$7f,$bfdd00
  149.         move.w    #$2000,$dff09c
  150.         movem.l    (a7)+,a5-a6
  151.         rte
  152.         
  153. dmaflags    ds.w    1
  154. repeatlen    ds.w    4
  155. repeatptr    ds.l    4
  156. _vbr        ds.l    1
  157.  
  158. sample        incbin    'atro:effects/lasertryr'
  159. sampleend
  160.